package br.mikhas.util.jdbc;

import java.sql.ResultSet;
import java.sql.SQLException;

public class SingleColumnRowMapper<T> implements RowMapper<T> {

	private final Class<T> requiredType;

	public SingleColumnRowMapper(Class<T> type) {
		this.requiredType = type;
	}

	@SuppressWarnings("unchecked")
	public T mapRow(int index, ResultSet rs) throws SQLException {
		return (T) JdbcUtils.getResultSetValue(rs, 1, this.requiredType);
	}

}
